package com.yjc.hire.work.controller;

import com.yjc.bo.WohLockMeRecord;
import com.yjc.eo.SearchResumeEO;
import com.yjc.hire.base.BaseInfoProperties;
import com.yjc.hire.grace.result.GraceJSONResult;
import com.yjc.hire.grace.result.PageGridResult;
import com.yjc.hire.work.service.CountsService;
import com.yjc.mo.HrCountMO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * </p>
 *
 * @author jcyin
 * @since 2025/9/10
 * </p>
 */

@RestController
@RequestMapping("counts")
public class CountsController extends BaseInfoProperties {

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @Autowired
    private CountsService countsService;

    @PostMapping("getCollectResumeCounts")
    public GraceJSONResult getCollectResumeCounts(@RequestBody String hrId) {
        String key =  HR_COLLECT_RESUME_COUNTS + ":" + hrId;
        return GraceJSONResult.ok(getCounts(key));

    }

    public Integer getCounts(String redisCountsKey){
        Integer count = 0;
        String countStr = stringRedisTemplate.opsForValue().get(redisCountsKey);
        if (StringUtils.isNoneBlank(countStr)){
            return Integer.valueOf(countStr);
        }
        return count;
    }

    @PostMapping("pageCollectResumeList")
    public GraceJSONResult pageCollectResumeList(Integer page,Integer pageSize,String hrId) {
        if (page == null) page = 0;
        if (pageSize == null) pageSize = 10;
        PageGridResult<List<SearchResumeEO>> listPageGridResult = countsService.queryPageCollectResumeList(page, pageSize, hrId);
        return GraceJSONResult.ok(listPageGridResult);
    }

    @PostMapping("addReadResumeRecord")
    public GraceJSONResult addReadResumeRecord() {
        return GraceJSONResult.ok();
    }

    @PostMapping("getReadResumeList")
    public GraceJSONResult getReadResumeList(Integer page, Integer pageSize, String hrId) {
        if (page == null) page = 0;
        if (pageSize == null) pageSize = 10;
        List<HrCountMO> hrCountMOS = countsService.queryReadResumeList(hrId, page, pageSize);
        return GraceJSONResult.ok(hrCountMOS);
    }

    @PostMapping("hrLookCand")
    public GraceJSONResult hrLookCand(@ RequestBody WohLockMeRecord wohLockMeRecord) {
        countsService.
    }
}
